import { IsEmail, IsOptional, MinLength, Matches } from 'class-validator';

export class UpdateUserDto {
    @IsOptional()
    @Matches(/^[a-zA-Z0-9_]{4,20}$/, { message: '用户名只能包含字母、数字和下划线，长度为4-20个字符' })
    username?: string;

    @IsOptional()
    @IsEmail({}, { message: '请输入有效的邮箱地址' })
    email?: string;

    @IsOptional()
    nickname?: string;

    @IsOptional()
    avatar?: string;

    @IsOptional()
    bio?: string;
}

export class ChangePasswordDto {
    @IsOptional()
    @MinLength(8, { message: '密码长度不能少于8个字符' })
    @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+]{8,}$/, {
        message: '密码需包含至少一个大写字母、一个小写字母和一个数字',
    })
    current_password: string;

    @MinLength(8, { message: '密码长度不能少于8个字符' })
    @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+]{8,}$/, {
        message: '密码需包含至少一个大写字母、一个小写字母和一个数字',
    })
    new_password: string;
} 